
#ifndef __PARTITION_GROUP
#define __PARTITION_GROUP

#include "../common/ptrlinkedlist.h"
#include "../common/sparse_matrix.h"

#define  DIVISIBLE 1
#define  INDIVISABLE 0
#define  NO_MORE_DIVISIBLE_GROUPS -1

typedef struct _partition_group
{
	int id;
	int parent_id;
	int divisible;
	int size;
	int* indices;
} partition_group;

typedef struct _partitions
{
	int number_of_partitions;
	int maxSize;
	/* partition_group** groups; */
	PtrLinkedList* divisible_groups;
	PtrLinkedList* non_divisible_groups;
} partitions;

partitions* init_partitions(sparse_matrix_arr* matrix);
partition_group* init_partiton_group(int* indices, int divisible, int size_of_indices);
void free_partitions(partitions* pGroup);
void free_partition_group(partition_group* partition);

void remove_from_partiton(partitions* pGroup,int index);/* remember to deallocate partition */
void add_to_partitions(partitions* pGroup, int* indices, int divisible, int size_of_indices);
void add_group_to_partitions(partitions* pGroup, partition_group* partition);

partition_group* pop_next_divisible(partitions* pGroup);
void set_divisiblity(partitions* pGroup, partition_group* partition,
					 int divisible);

void print_partitions(partitions* pGroup);/* prints all partitions */
void printPartitionGroup(partition_group* group);

#endif /*  __PARTITION_GROUP */
